/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lolskins;

import java.util.ArrayList;
import lolskins.event.Event;

/**
 *
 * @author Jargalan Nermunkh
 */
public class Framework {

    protected static Framework self = null;
    private ArrayList<IEventListener> listeners;

    private Framework(){
        listeners = new ArrayList<IEventListener>();
    }

    public static Framework getFramework(){
        if (self == null){
            self = new Framework();
        }

        return self;
    }

    public void registerListener(IEventListener listener){
        listeners.add(listener);
    }

    public void unregisterListener(IEventListener listener){
        listeners.remove(listener);
    }

    public void handleEvent(Event newEvent){
        for (int i = 0; i < listeners.size(); i++){
            listeners.get(i).handleEvent(newEvent);
        }
    }
    
}
